{% extends "base.html" %}
{% load i18n %}

{% block title %}{{ title }} | {% trans 'Magpie Site' %}{% endblock %}

{% block content %}

<div class="box">
<h2>Questions</h2>
<form action={% url knowledge.views.ask %} method="post">
<div id="content">
{% csrf_token %}
<ol>
{% for question in question_list %}
    <li>{{ question.prompt}}<br />
    <input type="radio" name='answer_{{question.id}}' value="y">Yes
    <input type="radio" name='answer_{{question.id}}' value="n">No
    </li>
{% endfor %}
</ol>
<input type="submit" value="Next" />
</div>
</form>
</div>

{%if priorQuestions%}
<div class="box">
<h2>Previously Answered</h2>
<form action={% url knowledge.views.saved %} method="post">
<div id="content">
{% csrf_token %}
<ol>
{% for question in priorQuestions %}
    <li>{{ question.0.prompt}}<br />
    <input type="radio" name='answer_{{question.0.id}}' value="y" {%if question.1 == 'Y' %}checked="checked"{%endif%}>Yes
    <input type="radio" name='answer_{{question.0.id}}' value="n" {%if question.1 == 'N' %}checked="checked"{%endif%}>No
    </li>
{% endfor %}
</ol>
<input type="submit" value="Change Answers" />
</div>
</form>
</div>
{%endif%}
{% endblock %}

{% block sidebar %}
{% if recommend_list %}
{% load customFilters %}
<div class="box">
<h2>Recommendations</h2>
<ol>
Tip: Click on the recommendations to see if they have additional resources.<br>
{% for rec in recommend_list %}
<input type="button" class="button" onclick="return toggleMe('{{rec.text|escapeForJS }}')" value="{{ rec.text}} ">
<br>
<div id="{{rec.text|escapeForJS}}" style="display:none">
    <ol>
    {% for link in rec.links %}
        <li><a href={{link.1}}>{{link.0}}</a> </li>
        {%if link.1|contains:"http://www.youtube.com/watch?v="%}
            {% with sliced=link.1|lslice:"31" %}
                {% with yTubeEmbed="\"http://www.youtube.com/embed/"|add:sliced|add:"\"" %}
                <iframe width="90%" height="400" src={{yTubeEmbed|safe}} frameborder="0" allowfullscreen></iframe> 
                {% endwith %}
            {% endwith %}
        {%endif%}
        {%if link.1|isImg %}
            <img src={{link.1}} width="90%"/>
        {% endif %}
    {% endfor %}
    </ol>
    {% if rec.pmlPath != None %}
        {% with pmlReq="\"pmlView?path="|add:rec.pmlPath %}
            <a href={{pmlReq|add:"&type=viewer"|add:"\""|safe}} />Click here to view the interactive PML Graph.</a><br>	
            <a href={{pmlReq|add:"&type=pml"|add:"\""|safe}} />Click here to view the PML specification.</a><br>	
            <a href={{pmlReq|add:"&type=roadmap"|add:"\""|safe}} />Click here to view the PML roadmap.</a><br>	
	    {% endwith %}
    {% endif %}
    {% if rec.vidLink != None %}
        <a class="vidPlayer"
             href={{rec.vidLink}}
            style="display:block;width:90%;height:400px;"> 
		</a> 
        <script>
			flowplayer("a.vidPlayer", "{% load adminmedia %}{% admin_media_prefix %}flowplayer-3.2.7.swf");
		</script>
    {% endif %}
</div>
{% endfor %}
</ol>
</div>
{% endif %}

{% if reason_list %}
<div class="box">
<h2>Reasons</h2>
<ol class="treeview">
{% for reason in reason_list %}
    <li>{{ reason.text }}</li>
    <ol>
    {% for qa in reason.qa_list %}
        <li>{{ qa.0|add:" You answered - " }} {{ qa.1|yesno:"Yes,No" }} </li>
    {% endfor %}
    </ol>
{% endfor %}
</ol>
</div>
{% endif %}
{% endblock %}
